<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>课程事件实例表管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript" src="/static/jquery/jquery.form.js"></script>
	<script type="text/javascript">
		// 上传答案文件的方法
        function uploadanswerfile() {
            var options={
                url:"/upload/uploadanswerfile",
                type:"post",
                dataType:"text",
                success:function(data){
                    //答案文件的url地址保存数据库
                    $("#answerFileUrl").val(data);

                }
            }
            $("#inputForm").ajaxSubmit(options);
        }
        // 上传作业文件的方法
        function uploadtaskfile() {
            var options={
                url:"/upload/uploadtaskfile",
                type:"post",
                dataType:"text",
                success:function(data){
                    // 作业文件的url地址保存数据库
                    $("#taskFileUrl").val(data);

                }
            }
            $("#inputForm").ajaxSubmit(options);
        }
        $(document).ready(function() {
            $("#value").focus();
            $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
        func
	</script>
</head>
<body>
<ul class="nav nav-tabs">
	<li><a href="${ctx}/business/eventcase">课程事件实例表</a></li>
	<li class="active"><a href="${ctx}/business/eventcase?id=${eventcase.id}">课程事件实例表<shiro:hasPermission name="business:eventcase:edit">${not empty eventcase.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="business:eventcase:edit">查看</shiro:lacksPermission></a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="eventCase" action="${ctx}/business/eventcase/save" method="post" class="form-horizontal">
	<form:hidden path="id"/>
	<tags:message content="${message}"/>
	  <div class="control-group">
      	<label class="control-label">问题ID:</label>
      	<div class="controls">
			<tags:pageselect id="question" name="question.id"
			value="${eventCase.question.id}" labelName="question.title"
			labelValue="${eventCase.question.title}"
			 title="问题" url="/business/question/select" width="800" height="540"
			cssClass="required"/>
      	</div>
      </div>
	<div class="control-group">
		<label class="control-label">作业文件上传（可上传多个）:</label>
		<td width="20%" class="pn-flabel pn-flabel-h">
			<span class="pn-frequired">*</span>
			上传作业文件:</td>
		<td width="80%" class="pn-fcontent">
			注：文件上传别超过32G。
		</td>
	</div>
	<div class="control-group">
		<label class="control-label">选择作业文件:</label>
		<div class="controls">
			<input type="file" name="taskfiles" onchange="uploadtaskfile()"/>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">作业地址:</label>
		<div class="controls">
			<form:input path="taskFileUrl" id="taskFileUrl"  name="taskFileUrl" htmlEscape="false" maxlength="250" class="required"/>
		</div>
	</div>

	<div class="control-group">
		<label class="control-label">答案文件上传（可上传多个）:</label>
		<td width="20%" class="pn-flabel pn-flabel-h">
			<span class="pn-frequired">*</span>
			上传答案文件:</td>
		<td width="80%" class="pn-fcontent">
			注:文件不要超过32G哦。
		</td>
	</div>
	<div class="control-group">
		<label class="control-label">选择答案文件:</label>
		<div class="controls">
			<input type="file" name="answerfile" onchange="uploadanswerfile()"/>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">答案文件地址:</label>
		<div class="controls">
			<form:input path="answerFileUrl" id="answerFileUrl"  name="answerFileUrl" htmlEscape="false" maxlength="250" class="required"/>
		</div>
	</div>

	<div class="form-actions">
		<shiro:hasPermission name="business:eventcase:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
		<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
	</div>
</form:form>
</body>
</html>